# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => 'a0c0d8cd570d30d3b46a122f1d424d04'
  
  def http_authenticate
    if !session[:token_key]
      login_url = {:controller => "sessions", :action => :login}
      respond_to do |wants|
        wants.html do
          redirect_to(login_url)
        end
        wants.js do
          render :update do |page|
            page.redirect_to(login_url)
          end
        end
      end
    else
      Remote.token_key = session[:token_key]
      true
    end
  end
end
